<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/include/taglibs.jsp"%>
<script type="text/javascript">

$(document).ready(function(){

});

function updateInfo(adm_seq, mem_seq){
// 	$("#lst").html(html);
	getEnc();
	location.href="./udtUsr.do?adm_seq="+adm_seq+"&mem_seq="+mem_seq+"&enc="+$("#enc").val();
}

function deleteInfo(adm_seq, mem_seq){
	if(confirm("삭제하시겠습니까?")){
		getEnc();
		location.href="./deleteInfo.do?adm_seq="+adm_seq+"&mem_seq="+mem_seq+"&enc="+$("#enc").val();
	}
}



function getEnc(){
	if(window.hwInfo){
		$("#enc").val(window.hwInfo.getInfo());	
	}
}
//목록 가져오기
function submitData(){
	if($("#info").val()==""){
		$("#lst").html("<img alt='' src='/camping/1.jpg' style='width: 100%;'>");
	}else{
		getEnc();
		$.ajax({
			url: "./usrList.do",
			dataType: "json",
			data : {"hp" : $("#info").val(),enc:$("#enc").val() },
			success : function (json){
//	 			console.log(json);
//	 			alert(json.list.length);
				if(json.list.length==0){
					$("#lst").html("<li>데이터가 없습니다</li>");
				}else{
					var html= 
					"<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class='party_tbl_new'>"+
					"	<col width=\"43%\">"+
					"	<col width=\"33%\">"+
					"	<col width=\"33%\">";
// 					"	<tr onclick=\"alert(222);\">"+
// 					"		<td style=\"height:53px\">논현-박철</td>"+
// 					"		<td style=\"height:53px\">김형욱</td>"+
// 					"		<td style=\"height:53px\">2014.05.03</td>"+
// 					"	</tr>"+
// 					"	<tr>"+
// 					"		<td style=\"height:53px;text-align: right;\" colspan=\"3\">"+
// 					"		->기타<br>가나나"+
// 					"		</td>"+
// 					"	</tr>"+
// 					"</table>";
					$.each(json.list, function (i) {

						html+=
						"	<tr onclick=\"showEtc('etc_"+i+"');\">"+
						"		<td class='border_empty' style=\"height:33px\">"+this.company+"("+this.hp_str+")"+"</td>"+
						"		<td style=\"height:53px\">"+this.nick+"</td>"+
						"		<td style=\"height:53px\">"+this.reg_date+"</td>"+
						"	</tr>"+
						"	<tr id=\"etc_"+i+"\" style='display:none;'>"+
						"		<td class='border_empty' style=\"height:33px;text-align: right;\" colspan=\"3\">";
						if(null!=this.etc){
							html+=this.etc;
							if(null!=this.sec_etc){
								html+=", "+this.sec_etc;
							}
						}else if(null!=this.sec_etc){
							html+=this.sec_etc;
						}
						
						if('Y'==this.edit_yn && 'Y'==json.roll2){
							html+="<br>";
							html+= "<a href='javascript:updateInfo(\""+this.adm_seq+"\",\""+this.mem_seq+"\")'>[수정]</a>";
							html+= "<a href='javascript:deleteInfo(\""+this.adm_seq+"\",\""+this.mem_seq+"\")'>[삭제]</a>";
						}

					});
					html+=
						"		</td>"+
						"	</tr>"+
						"</table>";
						$("#lst").html(html);
				}
				
			},
			error : function(error){
				seqChk = true;
				alert('접속지연이 발생했습니다. 몇분후에 다시 확인해주세요\n'+error);
			}
		});
	}
}
function showEtc(id){
	
	if("none"==$("#"+id).css("display")){
		$("#"+id).show();
	}else{
		$("#"+id).hide();
	}
	
}


</script>
<style type="text/css">
.party_tbl_new {
border-top:1px solid #bbbbbb;
}
.party_tbl_new tr td {
	padding-left :10px;
	border-bottom:1px solid #bbbbbb; 
	
}
.border_empty{
 border-left:0; 
}
</style>
<!-- <br> -->
<%-- ${roll } --%>
<!-- <br> -->
<div style="width:100%;">
<table cellpadding="0" cellspacing="0" width="100%">
	<col width="98px" >
	<col width=""  >
	<col width="48px"  >
  <tr>
    <td style="height:53px; background-image: url('/camping/left.png')"></td>
    <td style="height:53px; background-image: url('/camping/center.png')">
    <input id="info" name="info" value="" type="tel" style="width:100%;height: 30px;border-width:0;" />
    <input id="enc" name="enc" value="" type="hidden"/>
    </td>
    <td onclick="submitData();" style="height:53px; background-image: url('/camping/right.png')"></td>
  </tr>
  <tr>
  	<td colspan="3" id="lst">
  		<img alt="" src="/camping/1.jpg" style="width: 100%;">
  	</td>
  </tr>
<!--    <tr> -->
<!--   	<td colspan="3"> -->
  	
<!-- <table cellpadding="0" cellspacing="0" width="100%" class="party_tbl_new"> -->
<!-- 	<col width="33%"> -->
<!-- 	<col width="33%"> -->
<!-- 	<col width="33%"> -->
<!-- 	<tr onclick="alert(222);"> -->
<!-- 		<td class="border_empty" style="height:53px">논현-박철</td> -->
<!-- 		<td style="height:53px">김형욱</td> -->
<!-- 		<td style="height:53px">2014.05.03</td> -->
<!-- 	</tr> -->
<!-- 	<tr> -->
<!-- 		<td  class="border_empty" style="height:53px;text-align: right;" colspan="3"> -->
<!-- 		->기타<br>가나나 -->
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- 	<tr onclick="alert(222);"> -->
<!-- 		<td  class="border_empty" style="height:53px">논현-박철1</td> -->
<!-- 		<td style="height:53px">김형욱</td> -->
<!-- 		<td style="height:53px">2014.05.03</td> -->
<!-- 	</tr> -->
<!-- 	<tr> -->
<!-- 		<td style="height:53px;text-align: right;" colspan="3"> -->
<!-- 		->기타<br>가나나 -->
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- </table> -->
<!--   	</td> -->
<!--   </tr> -->
</table>
</div>

<c:if test="${'Y'==roll.roll2 }">
<button onclick="javascript:location.href='./intUsr.do';">등록</button>
</c:if>
